use serde::{Deserialize, Serialize};
use std::time::SystemTime;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Session {
    id: String,
    username: String,
    email: String,
    role: String,
    time: SystemTime,
}

impl Session {
    pub fn new(id: String, username: String, email: String, role: String) -> Self {
        Session {
            id,
            username,
            email,
            role,
            time: SystemTime::now(),
        }
    }

    pub fn is_expired(&self, duration: u64) -> bool {
        self.time.elapsed().unwrap().as_secs() >= duration
    }
}
